package com.theeviljames.coursework;

public class ParityFSM {

	/**
	 * Takes a binary string up to a length of 2^16 and returns
	 * the parity of the string. Simulates a FSM
	 * @param string
	 * @return
	 */
	public static int parity(String string){
		int parity = 0;
		for(char c:string.toCharArray())parity = (parity==1)?((c=='1')?0:1):((c=='0')?0:1);
		return parity;
	}
}
